<template>
  <div>

      <!-- <div class="boxClass"> -->
      <el-form
        :inline="true"
        style="text-align: center"
        ref="form"
        :model="form"
        label-width="100px"
      >
        <el-row>
          <el-col :span="24" style="text-align: left">
            <el-form-item prop="haveBusiness">
              <el-checkbox
                v-model="form.haveBusiness"
                style="font-size: 24px; font-weight: 700; color: #000"
                :true-label="1"
                :false-label="0"
                >业务推荐表下载</el-checkbox
              >
            </el-form-item>
          </el-col>
          <el-col :span="12" style="text-align: left">
            <el-form-item label="借款人姓名:" label-width="100px" prop="bn">
              <el-input
                v-model="form.bn"
                placeholder="请输入借款人姓名"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="身份证号码:" label-width="100px" prop="bc">
              <el-input
                v-model="form.bc"
                placeholder="请输入身份证号码"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12" style="text-align: left">
            <el-form-item label="申请金额:" label-width="100px" prop="lm">
              <el-input
                v-model="form.lm"
                placeholder="请输入申请金额"
                style="width: 87%"
                class="companyInput"
              ></el-input>
              <p class="company">万元</p>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              label="推荐函日期:"
              label-width="130px"
              prop="signDate"
            >
              <el-date-picker
                v-model="form.signDate"
                type="date"
                placeholder="选择日期"
                style="width: 87%; float: left"
                value-format="yyyy年MM月dd日"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12" style="text-align: left">
            <el-form-item label="贷款年限:" label-width="100px" prop="loanTerm">
              <el-input
                v-model="form.loanTerm"
                placeholder="请输入"
                style="width: 87%"
                class="companyInput"
                type="number"
              ></el-input>
              <p class="company">年</p>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <!-- </div> -->
      <el-form
        :inline="true"
        style="text-align: center"
        ref="form"
        :model="form"
        label-width="100px"
      >
        <el-row>
          <el-col :span="24" style="text-align: left">
            <el-form-item prop="haveGive">
              <el-checkbox
                v-model="form.haveGive"
                style="font-size: 24px; font-weight: 700; color: #000"
                :true-label="1"
                :false-label="0"
                >放弃租赁优先权承诺书</el-checkbox
              >
            </el-form-item>
          </el-col>
          <el-col :span="12" style="text-align: left">
            <el-form-item label="出租方姓名:" label-width="100px" prop="lessor">
              <el-input v-model="form.pledgeName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="房产地址:" label-width="100px" prop="address">
              <el-input v-model="form.address"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12" style="text-align: left">
            <el-form-item label="产权证号:" label-width="100px" prop="prcNo">
              <el-input v-model="form.prcNo"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <el-form
        :inline="true"
        style="text-align: center"
        ref="form"
        :model="form"
        label-width="100px"
      >
        <el-row>
          <el-col :span="24" style="text-align: left">
            <el-form-item prop="haveResolution">
              <el-checkbox
                v-model="form.haveResolution"
                style="font-size: 24px; font-weight: 700; color: #000"
                :true-label="1"
                :false-label="0"
                >股东会决议</el-checkbox
              >
            </el-form-item>
          </el-col>
          <el-col :span="12" style="text-align: left">
            <el-form-item
              label="借款人姓名:"
              label-width="100px"
              prop="borrower"
            >
              <el-input v-model="form.borrower"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              label="会议时间:"
              label-width="130px"
              prop="meetingDate"
            >
              <el-date-picker
                v-model="form.meetingDate"
                type="date"
                placeholder="选择日期"
                value-format="yyyy年MM月dd日"
                style="width: 87%; float: left"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12" style="text-align: left">
            <el-form-item
              label="公司名称:"
              label-width="100px"
              prop="corporateName"
            >
              <el-input v-model="form.corporateName"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div style="text-align: center">
        <el-button type="primary" style="width: 150px" @click="upData"
          >下载</el-button
        >
      </div>
  </div>
</template>
<script>
import {
  referenceFormRYD,
  referenceFormLYB,
  getOrderTable
  // referenceFormData,
} from "../../assets/js/api";
export default {
  props: {
    isContract: {
      type: Number
    },
    indexTrue: {
      type: Boolean
    },
    orderData: {
      type: String
    },
    showForm:{
      type:Object
    }
  },
  data() {
    return {
      form: {
        bc: "", //身份证号码!
        bn: "", //借款人姓名!
        lm: "", //申请金额!
        signDate: "", //推荐函日期!
        prcNo: "", //房产权证号
        address: "", //房产地址
        lessor: "", //出租方姓名
        haveResolution: 0, //是否下载股东会决议
        haveGive: 0, //是否下载放弃租赁优先权承诺书
        haveBusiness: 1, //是否下载业务推荐表
        meetingDate: "", //会议时间
        borrower: "", //股东会议下的借款人姓名
        corporateName: "" ,//公司名称
        loanTerm:'',//贷款年限
      }
      // businessDialogVisible: true,
    };
  },
  computed: {
    businessDialogVisible: {
      get() {
        return this.indexTrue;
      },
      set() {}
    }
  },
  switch: {
    businessDialogVisible(value) {
      if (value) {
        this.getData();
      }
    }
  },
  created() {
    this.getData();
  },
  methods: {
    // 获取数据!
    getData() {
      getOrderTable(this.orderData).then(res => {
        var infoData = res.data;
        this.form.bc = infoData.basicBorrowerCard;
        this.form.bn = infoData.basicBorrowerName;
        this.form.lm = infoData.contractGuaranteeMoney;
        this.form.address = infoData.pledgeHouseAddress;
        this.form.borrower = infoData.basicBorrowerName;
        this.form.corporateName = infoData.basicBorrowerWork;
        this.form.lessor = infoData.basicBorrowerName;
        this.form.prcNo = infoData.pledgeHouseNumber;
        this.form.pledgeName = infoData.pledgeName;
      });
    },
    upData() {
      this.form.productType=this.showForm.productType;
      //判断是否有勾选
      const isCheckBtn = this.isCheck();
      if (!isCheckBtn) {
        this.open();
        return;
      }
      // 如果产品是融银贷调用这个接口!
      if (this.isContract == 2) {
        referenceFormRYD(this.form).then(res => {
          window.location = res;
        });
      } else {
        // 其他产品使用这个接口!
        referenceFormLYB(this.form).then(res => {
          window.location = res;
        });
      }
    },
    //勾选事件
    isCheck() {
      //判断是否有勾选
      if (
        this.form.haveResolution == 1 ||
        this.form.haveGive == 1 ||
        this.form.haveBusiness == 1
      ) {
        return true;
      } else {
        return false;
      }
    },


    // 取消按钮!
    cancel() {
      this.$refs.form.resetFields();
      this.$emit("down", false);
    },
    open() {
      this.$alert("请勾选需要下载的内容", "", {
        confirmButtonText: "确定"
      });
    }
  }
};
</script>
<style lang="less" scoped>
.el-form {
  margin-bottom: 28px;
  padding: 22px 22px 0 22px;
  border: 1px #eee solid;
}
.company {
  float: right;
  width: 30px;
  text-align: center;
}

.companyInput {
  width: calc(100% - 30px);
}
</style>
